import { request } from '@boeyo/portal';
import { AxiosRequestConfig } from 'axios';

// 下载设备模板
export const downloadTemplate = async () => {
  return await request({
    url: '/device/downloadTemplate',
    method: 'POST',
    responseType: 'blob',
  });
};

// 模板导入
export const importTemplate = (data: any, config: AxiosRequestConfig<any>) => {
  return request({
    url: '/device/importData',
    method: 'POST',
    data,
    ...config,
  });
};
/**
 * 批量导入
 */
export const importBatch = (data: any) => {
  return request({
    url: '/device/importBatch',
    method: 'POST',
    data,
  });
};
//设备列表
export const getDeviceList = async (params: any) => {
  return await request({
    url: 'device/list',
    method: 'GET',
    params,
  });
};

/**
 * 删掉接入设备
 */
export const deleteDevice = (ids: number[]) => {
  return request({
    url: `/device/delete/${ids.join()}`,
    method: 'DELETE',
  });
};
/**
 * 更新接入设备
 */
export const updateDevice = (data: any) => {
  return request({
    url: '/device/update',
    method: 'PUT',
    data,
  });
};

/**
 * 设备列表校验
 */
export const checkDevice = (data: any) => {
  return request({
    url: '/device/check',
    method: 'POST',
    data,
  });
};

/**
 * 触发信息
 * @ss.hasPermi('device:triggerInfo')
 */
export const getTriggerInfo = (stationId) => {
  return request({
    url: `device/triggerInfo/${stationId}`,
    method: 'GET',
  });
};

/**
 * 参数信息修改
 */
export const updateDeviceParams = (data: any) => {
  return request({
    url: 'device/updateParam',
    method: 'POST',
    data,
  });
};
